import aaf
import os

def printProperties(AAFObject,tab=""):
    if "AAFFraction" in str(type(AAFObject)):
        return
    if "AUID" in str(type(AAFObject)):
        return
    if "MobID" in str(type(AAFObject)):
        return
    if "TypeDefRecord" in str(type(AAFObject)):
        return
    for object_key in AAFObject.all_keys():
        property = AAFObject.get(object_key)
        key_name = str(object_key)
        key_type = type(property)
        key_value= AAFObject.get_value(object_key)
        print tab + "[" + key_name + "]" + "(" + str(key_type) + "):" + str(key_value)
        # print type(key_value)
        if "aaf" in str(type(key_value)):
            if "PropValueResolveIter" not in str(type(key_value)):
                printProperties(key_value,tab=tab + "       ")
            else:
                for index in range(len(key_value)):
                    pro_object = key_value[index]
                    if "int" in str(type(pro_object)):
                        continue
                    pro_type = type(key_value[index])
                    pro_name = pro_object.name
                    if "NoneType" not in str(type(key_value[index])):
                        print tab + "       " + key_name + "[" + str(index) + "]." + str(key_value[index].name) + "(" + str(type(key_value[index])) + "):" + str(key_value[index])
                        if "aaf" in str(type(key_value[index])):
                                printProperties(key_value[index],tab + "                ")
    pass


output_aaf = 'resources/onlyone.aaf'

aaf_file = aaf.open(output_aaf, 'r')
print "[aaf_file]:" + str(aaf_file)
print

class_iid = aaf_file.class_iid
header = aaf_file.header
storage = aaf_file.storage
dictionary = aaf_file.dictionary

print "[aaf_file.class_iid]:" + str(class_iid)
print "[aaf_file.header]:" + str(header)
print "[aaf_file.storage]:" + str(storage)
print "[aaf_file.dictionary]:" + str(dictionary)
print

print "header:"
printProperties(header)
print

print "storage:"
printProperties(storage)
print

print "dictionary:"
printProperties(dictionary)
print

aaf_file.close()